/**
 * 
 */
package ch.unizh.ifi.ailab.ai;

import ch.unizh.ifi.ailab.dataTypes.Command;
import ch.unizh.ifi.ailab.dataTypes.SensorData;

/**
 * @author hans jaeckle jaeckle@gmail.com
 * 
 */
public abstract class SensorMotorCoupling { 

	/**
	 * doSMC does the calculations for the Sensor Motor Coupling
	 * 
	 * @param command
	 *            actual command that must be updated with the calculated
	 *            reaction.
	 */
	abstract public void calculateMotionCommand(SensorData data, Command command)
			throws UnavoidableObjectException;

	public String getSMCType() {
		return this.getClass().toString();
	}

	/**
	 * berechnet den winkel eines vektors
	 * 
	 * @param norm
	 *            laenge des vektors
	 * @param yVal
	 *            y wert des vektors (vorzeichen!)
	 * @return winkel im bogenmass! 8-TUNG: verifizieren: asin() nur fr -90 bis
	 *         90 grad definiert!
	 */
	protected double getAngle(double norm, double yVal) {
		return Math.asin(yVal / norm);
	}

	/**
	 * berechnet die laenge eines vektors (norm) aus seinen polarkoordinaten
	 * 
	 * @param xVal
	 *            x wert des vektors
	 * @param yVal
	 *            y wert des vektors
	 * @return laenge des vektors
	 */
	protected double getNorm(double xVal, double yVal) {
		return Math.sqrt(xVal * xVal + yVal * yVal);
	}
}
